﻿using Habanero.Base.Exceptions;

namespace Firestarter.DB.Schema.UI.RevEngDBWizard
{
    public class FileExtensionFilterElement
    {
        public string Extension { get; set; }
        public string Description { get; set; }
        public string ExtensionFilter { get; private set; }

        public bool IsValid()
        {
            return (!(string.IsNullOrEmpty(this.Extension) || string.IsNullOrEmpty(this.Description)));
        }

        public void Format()
        {
            if (!IsValid()) throw new HabaneroDeveloperException("The filter is not valid.  Extension and Description are required. e.g. Extension=mdb, Description=Microsoft Access");
            ExtensionFilter = string.Format("{0} (*.{1})|*.{1}", Description, Extension);
        }

    }
}